The present invention relates generally to a method, system and computer program product for database management, and more particularly for allocating free space in a database.
A relational database is a digital database whose organization is based on the relational model of data. This model organizes data into one or more tables, or relations, of rows and columns, with a unique key for each row. Rows in a database are also referred to as records. Generally, each entity type described in a database has its own table, the rows representing instances of that type of entity and the columns representing values attributed to that instance. Because each row in a table has its own unique key, rows in a table can be linked to rows in other tables by storing the unique key of the row to which it should be linked. Data relationships of arbitrary complexity can be represented using this set of concepts. The various software systems used to maintain relational databases are known as relational database management systems (RDBMS). Typically, relational database systems use SQL (Structured Query Language) as the language for querying and maintaining the database.
In a typical SQL database, the fundamental unit of data storage is the page, or block. The disk space allocated to a data file in a database is logically divided into pages numbered consecutively. Disk I/O operations are performed at the page level. That is, the database server reads or writes whole pages. Data pages include data rows of a table, typically put on the page serially, starting immediately after a header with control information.
A table space is a storage location where the actual data underlying database objects can be kept. It provides a layer of abstraction between physical and logical data, and serves to allocate storage for database objects, such as tables and indexes, that occupy physical space.
Databases usually have a clustering index (sometimes called a clustered index or index-organized table), which determines how rows are physically ordered, or clustered, in a table space. That is, for a table with a clustering index, the order of the rows in the data pages corresponds to the order of the rows in the index. Clustering indexes may provide significant performance advantages for some database operations, particularly those that involve a range of rows. When a table has a clustering index, an insert statement typically causes rows to be inserted as nearly as possible in the order of their index values. As a result, rows in a column are likely to be close together, such that the database server can generally access all the rows in a single read. However, using a clustering index does not guarantee that all rows for a given column value are stored on the same page. The actual storage of rows depends on the size of the rows, the number of rows, and the amount of available free, or reserve, space. Moreover, some pages may contain rows for more than one column value.